import {CHANNEL_ARRAY} from "./schema";
import {CALL_API} from "../../middlewares/normalizrMiddleware";
import {getApi} from "../../../api/common";
import {CHANNELS_ACTIONS} from "../../../constants/ActionTypes";

const fetchChannels = (type = 'nav', number = 1) => (dispatch: Function) => {

  return dispatch({
    channelsType: type,
    [CALL_API]: {
      singlePage: false,
      types: CHANNELS_ACTIONS,
      schema: CHANNEL_ARRAY,
      api: getApi('/channels', {
        'page[number]': number,
        'page[size]': 6,
        'filter[channelSource]': 1,
        'sort': 'displayOrder',
      })
    }
  })
};
export default {
  fetchChannels,
};
